# -*- coding:utf-8 -*-
from twisted.enterprise import adbapi

class MySQLObject(object):
    def __init__(self, host, port, username, password, database):
        self.dbPool = adbapi.ConnectionPool("pymysql", host=host, port=port,
                                                    user=username, password=password,
                                                    charset="utf8", db=database)
        self.dbPool.start()#必须先启动数据库连接池的线程

    def __del__(self):
        self.dbPool.close()